$TITLE ('FUNCTIONS FOR DIRECT ACCESS TO THE IEN-REGISTERS')
$SYMBOLS
$NOXREF
$NOCOND
$NOMOD51
$NORB
$PAGELENGTH(80) PAGEWIDTH(110)
;************************************************************************
;*									*
;*    R T X - 5 1  :   INTERRUPT-ENABLE MASK SET/RESET FUNCTION CALLS   *
;*							     		*
;*----------------------------------------------------------------------*
;*                                                                      *
;*    Filename     :   RTXISET.A51                                      *
;*    Language     :   Keil A-51                                        *
;*    Dev. system  :   Keil uVision2                                    *
;*    Targetsystem :   Any system based upon 8051 up                    *
;*                                                                      *
;*    Purpose      :   Implements the oi_set_int_masks and the          *
;*                     oi_rest_int_masks function calls.                *
;*								     	*
;*----------------------------------------------------------------------*
;* Rev. |  Released   | Programmer    | Comments                        *
;*----------------------------------------------------------------------*
;* 0.1  |  29.6.1992  | Th. Fischler  | Module creation                 *
;* 5.00 | 20.10.1994  | E. Glatz      | Release 5.00                    *
;* 7.00 | 13.11.2001  | T. Mueller    | Release 7.00                    *
;************************************************************************
;*    Copyright 1991 .. 2001 METTLER  &  FUCHS  AG,  CH-8953 Dietikon   *
;************************************************************************


$INCLUDE (RTXDEBUG.INC)
$INCLUDE (RTXIMASK.INC)


;*----------------------------------------------------------------------*
;*	I M P O R T S
;*----------------------------------------------------------------------*

$INCLUDE (RTXCONST.INC)

;        FROM RTXCONF
; Processor specific interrupt enable masks
EXTRN    DATA  (?RTX_IE, ?RTX_IEN1, ?RTX_IEN2)
; Interrupt mask variables
EXTRN    DATA  (?RTX_NM_IE, ?RTX_D_IE, ?RTX_ND_IE)
EXTRN    DATA  (?RTX_NM_IE1, ?RTX_D_IE1, ?RTX_ND_IE1)
EXTRN    DATA  (?RTX_NM_IE2, ?RTX_D_IE2, ?RTX_ND_IE2)
; Interrupt-Mask Bits
EXTRN    BIT   (?RTX_ENA_INT_REG1, ?RTX_ENA_INT_REG2)


;*----------------------------------------------------------------------*
;*	E X P O R T S
;*----------------------------------------------------------------------*

PUBLIC  _oi_set_int_masks
PUBLIC  _oi_reset_int_masks


;*----------------------------------------------------------------------*
;*	P R O C E D U R E S
;*----------------------------------------------------------------------*

;*----------------------------------------------------------------------*
;*      OI_SET_INT_MASKS
;*----------------------------------------------------------------------*
;*      System call for setting specific Interrupt-Enable Bits
;*----------------------------------------------------------------------*
;*      Input:  - R7: Mask for IEN0
;*      -----   - R5: Mask for IEN1
;*              - R3: Mask for IEN2
;*
;*      Output: - R7: Function result (OK)
;*      ------
;*----------------------------------------------------------------------*

?RTX?_oi_set_int_masks?RTXIMASK     SEGMENT CODE
                                    RSEG ?RTX?_oi_set_int_masks?RTXIMASK

_oi_set_int_masks:
               DBG_SYS_ENTRY
               GLOBAL_INT_DISABLE

               MOV   A, R7
               ORL   A, #80H              ; To be sure IE-Bit is set
               ORL   ?RTX_NM_IE, A
               ORL   ?RTX_D_IE, A
               ORL   ?RTX_ND_IE, A
               ANL   A, #7FH              ; To be sure IE-Bit is not set
               ORL   ?RTX_IE, A
               JNB   ?RTX_ENA_INT_REG1, END_SET
               MOV   A, R5
               ORL   ?RTX_NM_IE1, A
               ORL   ?RTX_D_IE1, A
               ORL   ?RTX_ND_IE1, A
               ORL   ?RTX_IEN1, A
               JNB   ?RTX_ENA_INT_REG2, END_SET
               MOV   A, R3
               ORL   ?RTX_NM_IE2, A
               ORL   ?RTX_D_IE2, A
               ORL   ?RTX_ND_IE2, A
               ORL   ?RTX_IEN2, A

END_SET:       MOV   R7, #OK
               GLOBAL_INT_ENABLE
               DBG_SYS_EXIT
               RET


;*----------------------------------------------------------------------*
;*      OI_RESET_INT_MASKS
;*----------------------------------------------------------------------*
;*      System call for reset specific Interrupt-Enable Bits
;*----------------------------------------------------------------------*
;*      Input:  - R7: Mask for IEN0
;*      -----   - R5: Mask for IEN1
;*              - R3: Mask for IEN2
;*
;*      Output: - R7: Function result (OK)
;*      ------
;*----------------------------------------------------------------------*

?RTX?_oi_reset_int_masks?RTXIMASK     SEGMENT CODE
                                      RSEG ?RTX?_oi_reset_int_masks?RTXIMASK

_oi_reset_int_masks:
               DBG_SYS_ENTRY
               GLOBAL_INT_DISABLE

               MOV   A, R7
               CPL   A
               ORL   A, #80H              ; To be sure IE-Bit is set
               ANL   ?RTX_NM_IE, A
               ANL   ?RTX_D_IE, A
               ANL   ?RTX_ND_IE, A
               ANL   A, #7FH              ; To be sure IE-Bit is not set
               ANL   ?RTX_IE, A
               JNB   ?RTX_ENA_INT_REG1, END_RESET
               MOV   A, R5
               CPL   A
               ANL   ?RTX_NM_IE1, A
               ANL   ?RTX_D_IE1, A
               ANL   ?RTX_ND_IE1, A
               ANL   ?RTX_IEN1, A
               JNB   ?RTX_ENA_INT_REG2, END_RESET
               MOV   A, R3
               CPL   A
               ANL   ?RTX_NM_IE2, A
               ANL   ?RTX_D_IE2, A
               ANL   ?RTX_ND_IE2, A
               ANL   ?RTX_IEN2, A

END_RESET:     MOV   R7, #OK
               GLOBAL_INT_ENABLE
               DBG_SYS_EXIT
               RET

;
;   END OF MODULE
;
	END
